<?php
      
include(dirname(__FILE__).'/inc/config.php');
include(dirname(__FILE__).'/inc/listpage.class.php');
include(dirname(__FILE__).'/inc/tree.class.php');

include(dirname(__FILE__).'/inc/article.model.class.php');
include(dirname(__FILE__).'/inc/type.model.class.php');
include(dirname(__FILE__).'/inc/config.model.class.php');


//文章类
$TR  = new tree();
$DA  = new article();
$DT  = new type();
$DC  = new config();
$cfg = $DC->data;


//  /article.php?id=19
//  /article.php?id=86
$id = isset($_GET['id'])? intval($_GET['id']):0;
if(!$id){ header('location:index.php');die(); }  





//当前文章 
$art =  $DA->init($id);
if(!$art){ header('location:index.php');die(); }  
//当前文章 
$tid = $art['tid'] ;
$type =  $DT->init( $tid  );

//var_dump($DT);

//顶层栏目
//var_dump($DT->top());
//顶层栏目
//var_dump($DT->parent( 15 ));


//var_dump($art);
//var_dump($type);


// 文章模板  1.文章表  2.分类表  3.默认
$tempart = isset($art['tempart']) ? trim( $art['tempart']) : trim( $type['tempart'] );

$tempart = trim( $art['tempart']);
if( empty($tempart) ){ $tempart = trim( $type['tempart'] ); }
if( empty($tempart) ){ $tempart = 'article_defalut.php'; }

$temp = ROOT.'/temp/'.$tempart;

//$temp = realpath($temp);


if (file_exists(  $temp   )  and  !is_dir( $temp )) {
    include($temp);
} else {
    echo "模板文件 $temp does not exist";
}


//include($tempart);